﻿@inherits ListOperateTableBase<EmailServerConfigDto, Guid, EmailServerConfigEdit>
@page "/system_manager/email_server_config"
<div>
    <Table @ref="_table"
           TItem="EmailServerConfigDto"
           DataSource="@_datas"
           Total="_total"
           OnChange="@OnChange"
           @bind-PageIndex="_pageIndex"
           @bind-PageSize="_pageSize"
           @bind-SelectedRows="_selectedRows"
           Loading="@_tableLoading.Value"
           Context="model">
        <TitleTemplate>
            <ResourceAuthorize ResourceKey="system_manager_email_server_config_refresh">
                <TableSearch TDto="EmailServerConfigDto" OnSearch="(filterGroups)=>ReLoadTable(true)" @ref="this.tableSearch" DefaultValue="_defaultSearchValue"></TableSearch>
             </ResourceAuthorize>
            <Row>
                <AntDesign.Col Span="8">
                    <ResourceAuthorize ResourceKey="system_manager_email_server_config_delete_selected">
                        <Button Type="@ButtonType.Primary" Icon="delete" Danger OnClick="OnClickDeletes" Loading="_deletesBtnLoading">
                            @Localizer[SharedLocalResource.DeleteSelected]
                        </Button>
                    </ResourceAuthorize>
                </AntDesign.Col>
                <AntDesign.Col Span="16" Style="text-align:right">
                    <Space>
                        <ResourceAuthorize ResourceKey="system_manager_email_server_config_add">
                            <SpaceItem>
                                <Button Type="@ButtonType.Primary" Icon="plus" OnClick="OnClickAdd">
                                    @Localizer[SharedLocalResource.Add]
                                </Button>
                            </SpaceItem>
                        </ResourceAuthorize>
                        <ResourceAuthorize ResourceKey="system_manager_email_server_config_refresh">
                            <SpaceItem>
                                <Button Type="@ButtonType.Primary" Icon="reload" OnClick="ReLoadTable">
                                    @Localizer[SharedLocalResource.Refresh]
                                </Button>
                            </SpaceItem>
                        </ResourceAuthorize>
                    </Space>
                </AntDesign.Col>
            </Row>
        </TitleTemplate>
        <ColumnDefinitions>
            <ResourceAuthorize ResourceKey="system_manager_email_server_config_delete_selected">
                <Selection Key="@(model.Id.ToString())" />
            </ResourceAuthorize>
            <Column @bind-Field="@model.Name" Filterable />
            <Column @bind-Field="@model.Host" Filterable />
            <Column @bind-Field="@model.Port" Filterable />
            <Column @bind-Field="@model.AccountName" Filterable />
            <Column @bind-Field="@model.Tags">
                @foreach (EmailServerTag tag in model.GetEmailServerTagEnums())
                {
                    <TagPro Text="@EnumHelper.GetEnumDescriptionOrName(tag)"></TagPro>
                }
            </Column>
            <Column @bind-Field="@model.IsLocked" Filterable Title="@Localizer[SharedLocalResource.IsLocked]">
                <ResourceAuthorize ResourceKey="system_manager_email_server_config_lock">
                    <Authorized>
                        <Switch @bind-Value="@model.IsLocked" OnChange="e=>OnChangeIsLocked(model,e)"></Switch>
                    </Authorized>
                    <NotAuthorized>
                        <TagYesNo Yes="model.IsLocked"></TagYesNo>
                    </NotAuthorized>
                </ResourceAuthorize>
            </Column>
            <Column @bind-Field="@model.CreatedTime" Format="@ClientConstant.DateTimeFormat" Sortable DefaultSortOrder="@SortDirection.Descending" Title="@Localizer[SharedLocalResource.CreatedTime]" />
            <ActionColumn>
                <Space>
                    <ResourceAuthorize ResourceKey="system_manager_email_server_config_edit">
                        <SpaceItem>
                            <Tooltip Title="@(Localizer[SharedLocalResource.Edit])" ArrowPointAtCenter="true">
                                <Button Icon="edit" Type="@ButtonType.Primary" Size="@ClientConstant.OperationButtonSize" OnClick="()=>OnClickEdit(model.Id)"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                    <ResourceAuthorize ResourceKey="system_manager_email_server_config_detail">
                        <SpaceItem>
                            <Tooltip Title="@(Localizer[SharedLocalResource.Detail])" ArrowPointAtCenter="true">
                                <Button Icon="eye" Type="@ButtonType.Primary" Size="@ClientConstant.OperationButtonSize" OnClick="()=>OnClickDetail(model.Id)"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                    <ResourceAuthorize ResourceKey="system_manager_email_server_config_send">
                        <SpaceItem>
                            <Tooltip Title="@(Localizer[SharedLocalResource.Send])" ArrowPointAtCenter="true">
                                <Button Icon="send" Type="@ButtonType.Primary" OnClick="()=>OnClickSend(model.Id)"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                    <ResourceAuthorize ResourceKey="system_manager_email_server_config_delete">
                        <SpaceItem>
                            <Tooltip Title="@(Localizer[SharedLocalResource.Delete])" ArrowPointAtCenter="true">
                                <Button Icon="delete" Type="@ButtonType.Primary" Danger OnClick="()=>OnClickDelete(model.Id)"></Button>
                            </Tooltip>
                        </SpaceItem>
                    </ResourceAuthorize>
                </Space>
            </ActionColumn>
        </ColumnDefinitions>
    </Table>
</div>